package com.dxj1992.utils.UserAsset;

import com.dxj1992.utils.Arith;

import java.math.BigDecimal;

public class Income extends Asset {
    @Override
    public void beforeUser() {
        this.setAmount(BigDecimal.valueOf(this.getAmount()).abs().doubleValue());
        this.setType(Asset.TYPE_INCOME);
    }

    @Override
    public void updateUserAsset() {
        // 更新平台余额、入库金额
        this.getUserAsset().setBalance(BigDecimal.valueOf(Arith.add(this.getUserAsset().getBalance().doubleValue(), this.getAmount())));
        this.getUserAsset().setTotalIncome(BigDecimal.valueOf(Arith.add(this.getUserAsset().getTotalIncome().doubleValue(), this.getAmount())));
        this.getIUserAssetService().updateById(this.getUserAsset());
    }

}
